import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { RoleQuery, RolePageResult, RoleForm } from "./types";

/**
 * 获取角色分页数据
 *
 * @param queryParams
 */
export function getAdminGroupList(
  queryParams?: RoleQuery
): AxiosPromise<RolePageResult> {
  return request({
    url: "/api/admin_group/index",
    method: "get",
    params: queryParams,
  });
}

/**
 * 新增权限(角色)组
 *
 * @param data
 */
export function addAdminGroup(data: RoleForm): AxiosPromise<DelResult> {
  return request({
    url: "/api/admin_group/add",
    method: "post",
    data: data,
  });
}

/**
 * 编辑权限(角色)组
 *
 * @param data
 */
export function editAdminGroup(
  id: string | number,
  data: RoleForm
): AxiosPromise<DelResult> {
  return request({
    url: `/api/admin_group/edit/id/${id}`,
    method: "post",
    data: data,
  });
}

/**
 * 删除权限(角色)组
 *
 * @param params
 */
export function deleteAdminGroup(
  ids: string,
  params: any
): AxiosPromise<DelResult> {
  return request({
    url: `/api/admin_group/del/ids/${ids}`,
    method: "get",
    params: params,
  });
}
